Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutter: refactor API dependency injection #7671

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Marchhill
Copy link
Contributor

Changes

  • Pass INethermindApi to Shutter Api constructor

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Documentation

Requires documentation update

  • Yes
  • No

@Marchhill Marchhill requested a review from ak88 October 28, 2024 14:23
@Marchhill Marchhill changed the title Shutter: refactor api dependency injection Shutter: refactor API dependency injection Oct 28, 2024
Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better would be refactor shutter to now use DI containers?

@asdacap
Copy link
Contributor

asdacap commented Oct 28, 2024

I think this went the other way around. We don't want to use INethermindApi. It hides the dependency.

I this case, I don't see any point in changing the code. Unless you want to make it easier/more reproducable for tests, in which case, this should do it:

using IContainer container = _api.ConfigureContainerBuilderFromApiWithNetwork(new ContainerBuilder())
  .AddSingleton<ShutterApi>()
  .AddOtherShutterDependencyThatShutterAPiUse()
  .AddSingleton<ShutterBlockHandler>() 
  .Build();

container.Resolve<ShutterApi>().StartP2P(thething);

Of course, put the configuration in a module is nicer.

@Marchhill
Copy link
Contributor Author

Ok, the aim was just to pass less arguments to API constructor. I'll have a look into DI containers

@Marchhill Marchhill marked this pull request as draft October 28, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants